package com.zyy.game.tianlong;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @author relufi
 */
@SpringBootApplication
@EnableCaching
@EnableAsync
@MapperScan("com.zyy.game.tianlong.dao")
public class TianlongApplication {

    public static void main(String[] args) {
        SpringApplication.run(TianlongApplication.class, args);
    }

    @Bean("taskExecutor")
    public Executor taskExecutor(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(1);
        executor.setMaxPoolSize(5);
        executor.setQueueCapacity(1024);
        executor.setThreadNamePrefix("Async-");
        executor.initialize();
        return executor;
    }
}
